﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Common
    {

        //  Math Methods

        #region Math methods
        
        /// <summary>
        /// get the max value from the parameter int[] array.
        /// </summary>
        /// <param name="iArray">int[] Array</param>
        /// <returns>max value</returns>
        public static int getMaximum(int[] iArray, out int index)
        {
            int maxValue = iArray[0];
            index = 0;
            for (int i = 1; i < iArray.Length; i++)
            {
                if (maxValue < iArray[i])
                {
                    maxValue = iArray[i];
                    index = i;
                }
            }
            return maxValue;
        }

        #endregion

        //  Array Methods

        #region Array Methods
        
        /// <summary>
        /// Initialize an int[] array with natural number(1, 2, 3, 4, 5, 6, ...).
        /// </summary>
        /// <param name="arr">an int[] array</param>
        public static void InitializeAnArray(int[] arr)
        {
            for (int i = 0; i < arr.Length; i++)
            {
                int j = i;
                arr[i] = ++j;
            }
        }

        #endregion

    }
}
